
fileName = 'MVI_0096.avi';
inputVideo = VideoReader(fileName);
load dataBase
num = numel(dataBase);
state = zeros(1,inputVideo.NumberOfFrames);
h1 = figure(1);
h2 = figure(2);
for ii = 1:inputVideo.NumberOfFrames
    img = read(inputVideo,ii);
    figure(h1)
    imshow(img);
    headImg = imcrop(img,[190,32,239,239]);
    desHoG = HoG(im2double(headImg));
    minD = realmax('double');
    for i = 1:num
        dist = chi2dist(dataBase(i).HoG,desHoG);
        if dist < minD
            minD = dist;
            lb = i;
        end
    end
    rectangle('position',[190,32,239,239]);
    text(190,32,dataBase(lb).label);
    drawnow
    pause(.01)
     figure(h2)
    state(ii) = str2double(dataBase(lb).label);
     plot(1:ii,state(1:ii));
     drawnow
end